<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="../../include.inc.jsp"%>
<link rel="stylesheet" type="text/css" href="${contextPath}/static/assets/css/bootstrap-datetimepicker.min.css" />
<div class="row">
    <div class="col-lg-12">
        <form id="formDlg" class="form-horizontal" role="form">
            <input type="hidden" id="id" name="id" value="${foodOrder.id}" />
            <!-- 数据权限 -->
            <div class="form-group">
                <label class="col-lg-3 control-label">订单状态:</label> <span class="text-danger">*</span>
                <div class="col-lg-8">
                    <x:dictData dictCode="Order_Type" var="orderTypes">
                        <x:select var="aTypes" items="${orderTypes}" id="type" name="type" className="form-control">
                            <x:option value="${aTypes.code }" text="${aTypes.name }" selected=""></x:option>
                        </x:select>
                    </x:dictData>
                </div>
            </div>
            <div class="form-group" hidden="true" id="disDiv">
                <label class="col-lg-3 control-label">配送时间:</label><span class="text-danger">*</span>
                <div class="col-lg-8">
                    <input type="datetime" readonly="readonly" class="form-control" id="dispatchTime" name="dispatchTime" value="${foodOrder.dispatchTime}"/>
                </div>
            </div>
            <div class="form-group" hidden="true" id="preDiv">
                <label class="col-lg-3 control-label">预计到达时间:</label><span class="text-danger">*</span>
                <div class="col-lg-8">
                    <input type="datetime" readonly="readonly" class="form-control" id="preFinishTime" name="preFinishTime" value="${foodOrder.preFinishTime}"/>
                </div>
            </div>
            <div class="form-group" hidden="true" id="reaDiv">
                <label class="col-lg-3 control-label">实际到达时间:</label><span class="text-danger">*</span>
                <div class="col-lg-8">
                    <input type="datetime" readonly="readonly" class="form-control" id="realFinishTime" name="realFinishTime" value="${foodOrder.realFinishTime}"/>
                </div>
            </div>
            <div class="form-group" hidden="true" id="resDiv">
                <label class="col-lg-3 control-label">取消原因:</label><span class="text-danger">*</span>
                <div class="col-lg-8">
                    <textarea class="form-control" id="reason" name="reason">${foodOrder.reason }</textarea>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript" src="${contextPath}/static/assets/js/date-time/bootstrap-datetimepicker.js"></script>
<script type="text/javascript" src="${contextPath}/static/assets/js/date-time/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript">
jQuery(function($) {
	$("#type").change(function(){
		var val = $(this).val();
		if(val == 3){
			$("#disDiv").show();
			$("#preDiv").show();
			$("#reaDiv").hide();
			$("#resDiv").hide();
		}
		else if(val == 4){
	        $("#disDiv").hide();
            $("#preDiv").hide();
            $("#reaDiv").show();
            $("#resDiv").hide();
		}
		else if(val == 5){
	        $("#disDiv").hide();
            $("#preDiv").hide();
            $("#reaDiv").hide();
            $("#resDiv").show();
		}
		else {
	        $("#disDiv").hide();
            $("#preDiv").hide();
            $("#reaDiv").hide();
            $("#resDiv").hide();
		}
	});
	var config = {//日期选择器
	        language : "zh-CN",
	        format : 'yyyy-mm-dd hh:ii'
	    };
	$("#dispatchTime").datetimepicker(config);
	$("#preFinishTime").datetimepicker(config);
	$("#realFinishTime").datetimepicker(config);
	
    $('#formDlg').validate({
        errorElement : 'span',
        errorClass : 'help-block',
        focusCleanup : false,
        focusInvalid : false,
        onsubmit : false,
        rules : {
            "dispatchTime":{required:true},
            "preFinishTime":{required:true},
            "realFinishTime":{required:true},
            "reason":{required:true}
        },
        messages : {
            "dispatchTime" : '请选择配送时间',
            "preFinishTime" : '请选择预计到达时间',
            "realFinishTime" : '请选择实际到达时间',
            "reason" : '请输入取消订单的原因',
        },
        highlight : function(e) {
            $(e).closest('.form-group').removeClass('has-info').addClass('has-error');
        },
        success : function(e) {
            $(e).closest('.form-group').removeClass('has-error').addClass('has-success');
            $(e).remove();
        },
    });
});
</script>